package com.kawa.kemanage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kawa.kemanage.entity.UserFeedback;
import com.kawa.kemanage.mapper.UserFeekbackMapper;
import com.kawa.kemanage.service.UserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserFeedbackServiceImpl implements UserFeedbackService {
    @Autowired
    private UserFeekbackMapper userFeekbackMapper;


    /**
     * 查询用户反馈列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<UserFeedback> queryFeekBack(Integer pageNo, Integer pageSize,String type,String status) {
        PageHelper.startPage(pageNo,pageSize);
        PageInfo pageInfo=new PageInfo(userFeekbackMapper.queryFeekbacke(type,status));
        return pageInfo;
    }


    @Override
    public UserFeedback selectFeekbackById(Integer feedback_id) {
        return userFeekbackMapper.selectFeekbackById(feedback_id);
    }

    //删除
    @Override
    public boolean delFeekback(Integer feedback_id) {
        return userFeekbackMapper.delFeekback(feedback_id)>0;
    }

//    增加
    @Override
    public boolean addFeekback(UserFeedback userFeedback) {
        return userFeekbackMapper.addFeekback(userFeedback)>0;
    }

    //修改
    @Override
    public boolean update(UserFeedback userFeedback) {
        return userFeekbackMapper.updateFeekback(userFeedback)>0;
    }


    //统计
    public Map<String, Integer> getFeedbackStats() {
        return userFeekbackMapper.countFeedbackByType();
    }

    @Override
    public List<UserFeedback> queryFeedbacksByUserId(Integer user_id) {
        return userFeekbackMapper.selectFeedBackByUserId(user_id);
    }
}
